package com.hospital.hospitalmedicalrecordservice.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hospital.common.dto.MedicalrecordDto;
import com.hospital.common.vo.ResultEntity;
import com.hospital.hospitalmedicalrecordservice.entity.Medicalrecord;
import com.hospital.hospitalmedicalrecordservice.entity.SeeaboutDto;
import com.hospital.hospitalmedicalrecordservice.service.IMedicalrecordService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 接诊表 前端控制器
 * </p>
 *
 * @author 韩天雨
 * @since 2020-10-20
 */
@RestController
@RequestMapping("/medicalrecord")
public class MedicalrecordController {


    @Autowired
    IMedicalrecordService iMedicalrecordService;
    @RequestMapping("/list")
    public ResultEntity list(MedicalrecordDto medicalrecordDto, Page page){
        IPage<Medicalrecord> medicalrecordPage = iMedicalrecordService.medicalrecordPageVo(medicalrecordDto,page);

        return ResultEntity.ok("200","成功",medicalrecordPage);
    }

    @RequestMapping("/num")
    public ResultEntity num(SeeaboutDto seeaboutDto){
        Date date = new Date();
        String newDateStr = DateFormatUtils.format(date,"yyyy-MM-dd");
        //System.out.println(newDateStr);

        String beginTime = newDateStr.concat(" 00:00:00");

        String entTime = newDateStr.concat(" 23:59:59");
        seeaboutDto.setTime1(beginTime);
        seeaboutDto.setTime2(entTime);
        List<Medicalrecord> medicalrecordnum = iMedicalrecordService.medicalrecordnum(seeaboutDto);


        return ResultEntity.ok(medicalrecordnum.size());
    }

}
